<?php

class StringUtils {
	
	static function strToCamel($str, $capitalizeFirst = true, $allowed = 'A-Za-z0-9') 
	{
	    return preg_replace(
	        array(
	            '/([A-Z][a-z])/e', 
	            '/([a-zA-Z])([a-zA-Z]*)/e',
	            '/[^'.$allowed.']+/e', 
	            '/^([a-zA-Z])/e'
	        ),
	        array(
	            '" ".$1', 
	            'strtoupper("$1").strtolower("$2")',
	            '', 
	            'strto'.($capitalizeFirst ? 'upper' : 'lower').'("$1")'
	        ),
	        $str
	    );
	}	
}

?>